export function getLabelFun (id, child) {
  //根
  let root = child.filter((item) => {
    return item.classifyParentID == id;
  })
  //除开根以外的所有子
  let child1 = child.filter((item) => {
    return item.classifyParentID != id;
  })
  let r = [];

  //循环根元素
  for (let i = 0; i < root.length; i++) {

    //判断当该根有没有子，0为true
    if (child1.filter((item) => {
      return item.classifyParentID === root[i].classifyID;
    }).length === 0) {
      //当为最根路径，就直接打印
      if (id == null) {
        let m = {
          value: root[i].classifyID,
          label: root[i].classifyName,
          children: []
        }
        r.push(m)
        if (r.length === root.length) {
          return r;
        }
        continue
        //不为最根则进行循环，但没有子
      } else {
        let m = {
          value: root[i].classifyID,
          label: root[i].classifyName,
          children: []
        }
        r.push(m);
        if (r.length === root.length) {
          return r;
        }
        continue;
      }
      //有子
    } else {
      let m = {
        value: root[i].classifyID,
        label: root[i].classifyName,
        children: getLabelFun(root[i].classifyID, child1)
      }
      r.push(m);
      if (r.length === root.length) {
        return r;
      }
    }
  }

}